<?php

namespace App\models\forum;

use App\mdoels\PostScript;
use Illuminate\Database\Eloquent\Model;

/**
 * App\models\forum\Partition
 *
 * @property int $id
 * @property string $title
 * @property string $display_name
 * @property string $description
 * @property string $img
 * @property int $index
 * @property bool $is_enable
 * @property int $falg
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property-read \App\models\forum\PartitionCategorie $partitionCategorie
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereTitle($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereDisplayName($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereDescription($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereImg($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereIndex($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereIsEnable($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereFalg($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Partition whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property-read \App\mdoels\PostScript $postscript
 */
class Partition extends Model
{
    public static function getForumPartitions(){
        return self::where('is_enable', 1)
            ->orderBy('index', 'ASC')
            ->get();
    }

    public function partitionCategorie(){
        return $this->belongsTo(PartitionCategorie::class, 'id', 'pid');
    }

    public function postscript(){
        return $this->belongsTo(PostScript::class, 'id', 'pid');
    }
}
